package com.qf.task;

import com.qf.event.DeviceStausCheckEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/*
 *  @author Administrator
 *  @version V1.0
 *  @Project smartdeviceplatgorm
 *  @Package com.qf.task
 *  @Description
 *  @Date2022/3/24 0024 21:32
 */
@EnableScheduling
@Component
public class DeviceStausCheckTask {
    private ApplicationContext context;
    @Autowired
    public void setContext(ApplicationContext context) {
        this.context = context;
    }

    @Scheduled(fixedRate = 45000)
    public void checkStaus() {
        //检查设备的最后一次时间,遍历所有的设备,告诉websocket你该去检查设备了
        context.publishEvent(new DeviceStausCheckEvent());
    }
}
